package com.ruoyi.iot.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.iot.domain.DeviceAcl;
import com.ruoyi.iot.service.IDeviceAclService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 该接口放开登录拦截
 */
@Slf4j
@RestController
@RequestMapping("/iot/mqtt")
public class DeviceAclController {

    @Resource
    private IDeviceAclService deviceAclService;

    @Anonymous
    @PostMapping("auth")
    public DeviceAcl auth(@RequestBody DeviceAcl deviceAcl){
        return deviceAclService.auth(deviceAcl);
    }

    @Anonymous
    @RequestMapping("superuser")
    public void superuser(HttpServletResponse response, DeviceAcl deviceAcl ) {
        response.setStatus(400);
    }

    @Anonymous
    @RequestMapping("acl")
    public DeviceAcl acl(@RequestBody  DeviceAcl deviceAcl) {
        return deviceAclService.acl(deviceAcl);
    }
}
